package com.community.body.service.impl;

import java.util.List;

import com.community.body.domain.ZyComment;
import com.community.body.dto.CommentDTO;
import com.community.body.mapper.ZyCommentMapper;
import com.community.body.service.IZyCommentService;
import com.community.body.vo.ZyCommentVO;
import com.community.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 评论Service业务层处理
 * 
 * @author community
 * @date 2024-04-17
 */
@Service
public class ZyCommentServiceImpl implements IZyCommentService
{
    @Autowired
    private ZyCommentMapper zyCommentMapper;

    /**
     * 查询评论
     * 
     * @param commentId 评论主键
     * @return 评论
     */
    @Override
    public ZyComment selectZyCommentByCommentId(Long commentId)
    {
        return zyCommentMapper.selectZyCommentByCommentId(commentId);
    }

    /**
     * 查询评论列表
     * 
     * @param zyComment 评论
     * @return 评论
     */
    @Override
    public List<CommentDTO> selectZyCommentList(ZyComment zyComment)
    {
        return zyCommentMapper.selectZyCommentList(zyComment);
    }

    /**
     * 新增评论
     * 
     * @param zyComment 评论
     * @return 结果
     */
    @Override
    public int insertZyComment(ZyCommentVO zyComment)
    {
        ZyComment comment = new ZyComment();
        comment.setContent(zyComment.getContent());
        comment.setDelFlag(0L);
        comment.setParentId(zyComment.getParentId());
        comment.setUserId(zyComment.getUserId());
        comment.setInteractionId(zyComment.getInteractionId());
        comment.setCreateTime(DateUtils.getNowDate());
        comment.setRemark(zyComment.getRemark());
        return zyCommentMapper.insertZyComment(comment);
    }

    /**
     * 修改评论
     * 
     * @param zyComment 评论
     * @return 结果
     */
    @Override
    public int updateZyComment(ZyComment zyComment)
    {
        Long commentID = zyComment.getCommentId();
        zyCommentMapper.updateCommentDelFlag(commentID);
        zyComment.setUpdateTime(DateUtils.getNowDate());
        zyComment.setDelFlag(1L);
        return zyCommentMapper.updateZyComment(zyComment);
    }

    /**
     * 批量删除评论
     * 
     * @param commentIds 需要删除的评论主键
     * @return 结果
     */
    @Override
    public int deleteZyCommentByCommentIds(Long[] commentIds)
    {
        return zyCommentMapper.deleteZyCommentByCommentIds(commentIds);
    }

    /**
     * 删除评论信息
     * 
     * @param commentId 评论主键
     * @return 结果
     */
    @Override
    public int deleteZyCommentByCommentId(Long commentId)
    {
        return zyCommentMapper.deleteZyCommentByCommentId(commentId);
    }
}
